<template>
  <view class="top_head pr"  >
  	<!-- #ifndef MP-WEIXIN -->
  	<view class="state_top"></view>
  	<!-- #endif -->
  	<view class="head_top" :style="'height:'+topBarTop()+'px;'"></view>
  	<view class="d-b-c" :style="topBarHeight() == 0 ? '': 'height:'+topBarHeight()+'px;'">
  		<view class="index_log">
  			<image :src="toplogo || '/static/logo.png'" mode=""></image>
  		</view>
  		<!-- #ifndef MP-WEIXIN -->
  		<view class="d-s-c flex-1">
  			<view class="top_search special" :style="'height:'+topBarHeight()+' px;'" @click="gotoPage('/shoppages/product/search/search')"><text
  				 class="icon iconfont icon-sousuo"></text>搜索商品</view>
  			<view class="top_search_right" @click="scanQrcode"><text class="icon iconfont icon-saoyisao1"></text></view>
  		</view>
  		<view class="d-e-c p-0-20">
  			<view class="news pr" @click="gotoPage('/shoppages/plus/chat/chat_list')">
  				<image class="chat" src="@/static/icon/chat.png" mode=""></image>
  				<view class="newsnum" v-if="msgNum">{{msgNum}}</view>
  			</view>
  		</view>
  		<!-- #endif -->
  		<!-- #ifdef MP-WEIXIN -->
  		<view class="d-s-c flex-1">
  			<view class="top_search special" :style="'height:'+topBarHeight()+' px;'" @click="gotoPage('/shoppages/product/search/search')"><text
  				 class="icon iconfont icon-sousuo"></text>搜索商品</view>
  			<view class="top_search_right" @click="scanQrcode"><text class="icon iconfont icon-saoyisao1"></text></view>
  		</view>
  		<view class="flex-1"></view>
  		<!-- #endif -->
  	</view>

  </view>

</template>

<script>
  export default{
    data(){
      return{

      }
    },
    props:{
      bgcolor:{
        type:String,
        default:''
      },
      msgNum:{
        type:Number,
        default:0
      },
      toplogo:{
        type:String,
        default:''
      }
    },
    methods:{
      /*扫一扫核销*/
      scanQrcode: function() {
      	let self = this;
      	//#ifdef H5
      	// 只允许通过相机扫码
      	self.jweixin.scanQRCode({
      		needResult: 1,
      		scanType: ["qrCode", "barCode"],
      		success: function(res) {
      			self.gotoPage('/shoppages/store/clerkorder?order_no=' + res.resultStr);
      		},
      		error: function(res) {
      			uni.showToast({
      				title: '扫码失败，请重试'
      			})
      		}
      	});
      	//#endif
      	//#ifndef H5
      	// 只允许通过相机扫码
      	uni.scanCode({
      		onlyFromCamera: true,
      		success: function(res) {
      			if (res.errMsg == 'scanCode:ok') {
      				self.gotoPage('/shoppages/store/clerkorder?order_no=' + res.result);
      			} else {
      				uni.showToast({
      					title: '扫码失败，请重试'
      				})
      			}
      		}
      	});
      	//#endif
    }
  },
  }
</script>

<style>

  .top_search {
    width: 380rpx;
    height: 60rpx;
    line-height: 60rpx;
    background: #ffffff;
    color: #999999;
    border-radius: 6rpx 0 0 6rpx;
    font-size: 26rpx;
    margin-left: 10rpx;
  }

  .top_search.special {
    width: 100%;
  }

  .top_search_right {
    background: #ffffff;
    border-radius: 0 6rpx 6rpx 0;
    height: 60rpx;
    /* padding: 0 20rpx; */
    /* border-left: 1rpx solid #D9D9D9; */
  }

  .top_search_right .icon-saoyisao1 {
    padding: 0 20rpx;
    border-left: 1rpx solid #d9d9d9;
  }

  .top_search .icon-sousuo {
    font-size: 26rpx;
    color: #999999;
    margin-left: 20rpx;
    margin-right: 10rpx;
  }

  .head_top {
    width: 100%;
    height: var(--status-bar-height);
  }

  .index_log {
    /* width: 154rpx; */
    min-height: 46rpx;
    line-height: 46rpx;
    font-size: 36rpx;
    color: #ffffff;
  }

  .index_log image {
    width: 60rpx;
    height: 60rpx;
  }
.newsnum {
  position: absolute;
  top: -8rpx;
  right: -16rpx;
  z-index: 100;
  border-radius: 50%;
  width: 25rpx;
  height: 25rpx;
  text-align: center;
  line-height: 25rpx;
  color: #ffffff;
  background-color: #55ffff;
  padding: 5rpx;
  font-size: 20rpx;
}
.chat {
  width: 40rpx;
  height: 40rpx;
}
.top_head {
    line-height: 30px;
    z-index: 1;
    padding-left: 26rpx;
  }
</style>
